﻿using System;
using System.Collections.Generic;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace ObTookit.HighLight
{
    public class SqlHighLight : BaseHighLight
    {
        private void SetWords()
        {
            DefaultColor = Color.Black;
            Keywords = new string[] { "ADD", "EXCEPT", "PERCENT  ALL", "EXEC", "PLAN  ALTER", "EXECUTE", "PRECISION  AND", "EXISTS", "PRIMARY  ANY", "EXIT", "PRINT  AS", "FETCH", "PROC  ASC", "FILE", "PROCEDURE  AUTHORIZATION", "FILLFACTOR", "PUBLIC  BACKUP", "FOR", "RAISERROR  BEGIN", "FOREIGN", "READ  BETWEEN", "FREETEXT", "READTEXT  BREAK", "FREETEXTTABLE", "RECONFIGURE  BROWSE", "FROM", "REFERENCES  BULK", "FULL", "REPLICATION  BY", "FUNCTION", "RESTORE  CASCADE", "GOTO", "RESTRICT  CASE", "GRANT", "RETURN  CHECK", "GROUP", "REVOKE  CHECKPOINT", "HAVING", "RIGHT  CLOSE", "HOLDLOCK", "ROLLBACK  CLUSTERED", "IDENTITY", "ROWCOUNT  COALESCE", "IDENTITY_INSERT", "ROWGUIDCOL  COLLATE", "IDENTITYCOL", "RULE  COLUMN", "IF", "SAVE  COMMIT", "IN", "SCHEMA  COMPUTE", "INDEX", "SELECT  CONSTRAINT", "INNER", "SESSION_USER  CONTAINS", "INSERT", "SET  CONTAINSTABLE", "INTERSECT", "SETUSER  CONTINUE", "INTO", "SHUTDOWN  CONVERT", "IS", "SOME  CREATE", "JOIN", "STATISTICS  CROSS", "KEY", "SYSTEM_USER  CURRENT", "KILL", "TABLE  CURRENT_DATE", "LEFT", "TEXTSIZE  CURRENT_TIME", "LIKE", "THEN  CURRENT_TIMESTAMP", "LINENO", "TO  CURRENT_USER", "LOAD", "TOP  CURSOR", "NATIONAL", "TRAN  DATABASE", "NOCHECK", "TRANSACTION  DBCC", "NONCLUSTERED", "TRIGGER  DEALLOCATE", "NOT", "TRUNCATE  DECLARE", "NULL", "TSEQUAL  DEFAULT", "NULLIF", "UNION  DELETE", "OF", "UNIQUE  DENY", "OFF", "UPDATE  DESC", "OFFSETS", "UPDATETEXT  DISK", "ON", "USE  DISTINCT", "OPEN", "USER  DISTRIBUTED", "OPENDATASOURCE", "VALUES  DOUBLE", "OPENQUERY", "VARYING  DROP", "OPENROWSET", "VIEW  DUMMY", "OPENXML", "WAITFOR  DUMP", "OPTION", "WHEN  ELSE", "OR", "WHERE  END", "ORDER", "WHILE  ERRLVL", "OUTER", "WITH  ESCAPE", "OVER", "WRITETEXT" };
            KeywordColor = Color.Blue;

            Functions = new string[] { };
            FunctionColor = Color.Red;
        }
        public void SetWordsColor(System.Windows.Forms.RichTextBox rtb, string rtbText)
        {
            SetWords();
            rtb.SelectAll();
            rtb.SelectionColor = Color.Black;
            string text = rtb.Text;
            SetHighLight(rtb, text, Keywords, KeywordColor);
            SetHighLight(rtb, text, Functions, FunctionColor);
        }
    }
}
